
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>

#include "PlayerObject.h"
#include "PlayerObjectManager.h"

int main(int argc, char *argv[])
{
    std::vector<std::string> vecDefFiles;
    vecDefFiles.push_back( "../worlds/tables.inc" );
    vecDefFiles.push_back( "../worlds/person.inc" );
    PlayerObjectManager::Instance().ParseConfigFile( vecDefFiles, "../worlds/simple.world" );

    std::fstream fsObjConfigReader;
    fsObjConfigReader.open( "Standby.plantree.csv", std::ios_base::in );
    if ( !fsObjConfigReader.is_open() )
    {
        return 0;
    }

    std::string strLine = "";
    double dPosY = 0.0;
    double dPosX = 0.0;

    while ( !fsObjConfigReader.eof() )
    {
        if ( fsObjConfigReader.bad() )
        {
            break;
        }

        std::getline( fsObjConfigReader, strLine );

        if ( strLine.empty() )
        {
            continue;
        }

        std::stringstream stmSplitter( strLine );
        std::getline( stmSplitter, strLine, ',' );

        {
            std::stringstream stmConvertor( strLine );
            stmConvertor >> dPosX;
        }

        std::getline( stmSplitter, strLine, ',' );

        {
            std::stringstream stmConvertor( strLine );
            stmConvertor >> dPosY;
        }
        
        //if ( PlayerObjectManager::Instance().GetStaticObjects().at(0).isCollided( dPosX, dPosY, 0.36 ) )
        //{
        //std::cout << "Collided when at [" << dPosX << ", " << dPosY << "]" << std::endl;
        //}
    }

    dPosX = 0.639215;
    dPosX = 0.531152;
    if ( PlayerObjectManager::Instance().GetStaticObjects().at(0).isCollided( dPosX, dPosY, 0.36 ) )
    {
        std::cout << "Collided when at [" << dPosX << ", " << dPosY << "]" << std::endl;
    }

    dPosX = -0.79;
    dPosX = -0.83;
    if ( PlayerObjectManager::Instance().GetStaticObjects().at(0).isCollided( dPosX, dPosY, 0.36 ) )
    {
        std::cout << "Collided when at [" << dPosX << ", " << dPosY << "]" << std::endl;
    }
}